<template>
  <div class="layout">
    <div class="aside">
      <div class="logo">
        <img src="../assets/logo.png" alt="" />
        <span>Manager</span>
      </div>
      <el-menu
        :default-active="$route.path"
        :router="true"
        background-color="#001529"
        text-color="#fff"
        active-text-color="#ffd04b"
      >
        <item :menuList="menuList"></item>
      </el-menu>
    </div>
    <div class="content">
      <div class="top">
        <div class="left">
          <div class="icon">
            <i class="el-icon-s-fold"></i>
          </div>
          <div class="bread">
            <!-- 面包屑 -->
            <bread-crumb></bread-crumb>
          </div>
        </div>
        <div class="user-info">
          <el-badge class="notice">
            <i class="el-icon-bell"></i>
          </el-badge>
          <!-- 下拉菜单 -->
          <el-dropdown>
            <span class="el-dropdown-link user-link">
              {{ $store.state.userInfo.userName || "" }}
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item
                >邮箱: {{ $store.state.userInfo.userEmail }}</el-dropdown-item
              >
              <el-dropdown-item>退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </div>
      <div class="bottom">
        <div class="main">
          <router-view></router-view>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import BreadCrumb from "./BreadCrumb.vue";
import Item from "./Item.vue";
export default {
  components: { Item, BreadCrumb },
  data() {
    return {
      menuList: [],
    };
  },
  mounted() {
    this.getMenuList();
  },
  methods: {
    async getMenuList() {
      let res = await this.userApi.getMenuList();
      this.$store.commit("saveMenuList", res.menuList);
      this.$store.commit("saveActionList", res.actionList);
      this.menuList = res.menuList;
    },
  },
};
</script>

<style scoped lang='scss'>
.layout {
  position: relative;
  .aside {
    position: fixed;
    width: 200px;
    height: 100vh;
    background-color: #001529;
    color: #fff;
    overflow-y: auto;
    .logo {
      display: flex;
      align-items: center;
      font-size: 18px;
      height: 50px;
      img {
        margin: 0 16px;
        width: 32px;
        height: 32px;
      }
    }
    .el-menu {
      border-right: none;
    }
  }
  .content {
    margin-left: 200px;
    .top {
      height: 50px;
      background-color: #fff;
      padding: 0 20px;
      border-bottom: 1px solid #ddd;
      display: flex;
      align-items: center;
      justify-content: space-between;
      position: absolute;
      right: 0;
      z-index: 9999;
      left: 200px;
      .left{
        display: flex;
        align-items: center;
        .icon{
          font-size: 18px;
          margin-right: 15px;
        }
      }
      .user-info{
        .notice{
          margin-right: 15px;
          line-height: 30px;
          cursor: pointer;
        }
        .user-link{
          cursor: pointer;
          color: #409eff;
        }
      }
    }
    .bottom{
      background: #eef0f3;
      height: 100%;
      padding: 20px;
      padding-top: 71px;
      .main{
        min-height: calc(100vh - 50px);
        height: 100%;
      }
    }
  }
}
</style>
